<template>
	<!-- 劳模风采 -->
	<view class="content">
		<up-sticky bgColor="#eee">
			<view class="worker-wrap">
				<up-tabs
				:scrollable="false"
				:current="current"
				:list="tabList"
				@click="tabsClick"
				lineWidth="0"
				lineHeight="0"
				:activeStyle="{ color: '#fff', fontSize: '30rpx', fontWeight: 'bold',background:'#ff4e4e',padding:'10rpx',width:'100%',textAlign:'center',borderRadius:'10rpx' }"
				:inactiveStyle="{ fontSize: '30rpx', fontWeight: 'bold',background:'#fff',padding:'10rpx',width:'100%',textAlign:'center',borderRadius:'10rpx' }"
				></up-tabs>
			</view>
		</up-sticky>
		<view class="worker-list">
			 <scroll-view
			      class="scroll-view"
			      scroll-y
			      @scrolltolower="getPersonalHonorList"
				  v-if="current == 0"
			    >
				<view class="worker-item" v-for="(item,index) in personalHonorList" :key="index" @tap="getDetail(item.id)" >
					<up-avatar :src="item.avatar" shape="square" size="70px" style="padding-left: 16rpx;"></up-avatar>
					<!-- <up-image :src="item.avatar" width="122rpx" height="144rpx" mode="aspectFit" radius="5"></up-image> -->
					<view class="worker-info">
						<view class="info-item">
							<view>{{item.realName}}</view>
							<view>{{item.orgName}}</view>
						</view>
						<view class="info-item">
							<!-- <view>单位</view>
							<view>{{item.orgName}}</view> -->
							<view>
								<u-tag :text="item.levelStr"  size="mini" type="success" style="margin-right: 10rpx;"></u-tag>
								<u-tag :text="item.categoryStr"  size="mini" type="warning"></u-tag>
							</view>
						</view>
						<view class="info-item">
							<view>{{item.createTime}}</view>
						</view>
					</view>
				</view>
				<view style="padding-top: 200rpx">
					<up-empty mode="data" text="暂无数据" icon="https://jqgh-public.yqfoodec.com/20250405/%E7%BB%84%2016@2x_53897.png" v-if="personalHonorList.length == 0"></up-empty>
				</view>
			</scroll-view>
			<scroll-view
			     class="scroll-view"
			     scroll-y
			     @scrolltolower="getCommunityHonorList"
				 v-if="current == 1"
			   >
				<view class="worker-item" v-for="(item,index) in communityHonorList" :key="index" @tap="getCommunityDetail(item.id)" >
					<view class="community-info">
						<view class="c-info-item">
							<view class="info-item-name">{{item.name}}</view>
							<view>{{item.orgName}}</view>
						</view>
						<view class="c-info-item">
							<view class="label-view">
								<u-tag :text="item.levelStr"  size="mini" type="success" style="margin-right: 10rpx;"></u-tag>
								<u-tag :text="item.categoryStr"  size="mini" type="warning"></u-tag>
							</view>
							<view>{{item.createTime}}</view>
						</view>
					</view>
				</view>
				<view style="padding-top: 200rpx">
					<up-empty mode="data" text="暂无数据" icon="https://jqgh-public.yqfoodec.com/20250405/%E7%BB%84%2016@2x_53897.png" v-if="communityHonorList.length == 0"></up-empty>
				</view>
			</scroll-view>
			
		</view>
	</view>
</template>

<script>
	import publicityList from '@/components/publicity-list.vue'
	import {personalHonorApi} from '@/api/talent/personal-honor-api.js';
	import {communityHonorApi} from '@/api/talent/community-honor-api.js';
	export default {
		components: {
			publicityList
		},
		data() {
			return {
				tabList: [
					{
						name: '个人荣誉'
					},
					{
						name: '集体荣誉'
					}
				],
				current: 0,
				pageRequest:{
					page:1,
					limit:10,
				},
				communityRequest:{
					page:1,
					limit:10,
				},
				personalHonorList:[],
				communityHonorList:[],
				hasMore: true, // 是否还有更多数据
				communityHasMore: true,

			}
		},
		onLoad(options) {
			if(options.current) {
				this.current = Number(options.current)
			}
			if(!options.current || options.current == 0){
				this.getPersonalHonorList();
			}
			if(options.current == 1){
				this.getCommunityHonorList();
			}
			
		},
		methods: {
			tabsClick(e) {
				const index = e.index;
				if(index === 0){
					this.getPersonalHonorList();
				}
				if(index === 1){
					this.getCommunityHonorList();
				}
				this.current = index;
			},
			getDetail(id) {
				uni.navigateTo({
				    url: '../model-worker/detail?id='+id
				});
			},
			getCommunityDetail(id) {
				uni.navigateTo({
				    url: '../model-worker/community-detail?id='+id
				});
			},
			/**
			 * 个人荣誉列表
			 */
			async getPersonalHonorList(){
				const result = await personalHonorApi.queryList(this.communityRequest);
				if(result.data.list.length > 0){
					this.personalHonorList.push(...result.data.list);
					this.communityRequest.page++;
				}else {
					this.communityHasMore = false;
				}
			},
			
			/**
			 * 集体荣誉
			 */
			async getCommunityHonorList(){
				const result = await communityHonorApi.queryList(this.pageRequest);
				if(result.data.list.length > 0){
					this.communityHonorList.push(...result.data.list);
					this.pageRequest.page++;
				}else {
					this.hasMore = false;
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.content{
		height: 100vh;
		background-color: #eee;
	}
	.worker-wrap {
		// border-bottom: 5px solid #eee;
		width: 50%;
		padding: 0 20rpx;
	}
	.scroll-view{
		height: 90vh;
	}
	.worker-list {
		padding: 0 40rpx;
		/* #ifdef H5 */
		margin-top: 80rpx;
		/* #endif */
		.worker-item {
			display: flex;
			border-bottom: 1px solid #e5e5e5;
			padding: 30rpx 0;
			background-color: #fff;
			margin: 20rpx 0;
			border-radius: 10rpx;
			.worker-info {
				margin-left: 20rpx;
				color: #333333;
				font-size: 26rpx;
				line-height: 26px;
				width: calc(100% - 70px);
				padding-right: 16rpx;
				.info-item {
					display: flex;
					justify-content: space-between;
					.label-view {
						margin-right: 30rpx;
					}
				}
			}
			.community-info{
				margin-left: 20rpx;
				color: #333333;
				font-size: 26rpx;
				line-height: 26px;
				width: calc(100%);
				padding-right: 16rpx;
				.c-info-item {
					display: flex;
					justify-content: space-between;
					.info-item-name{
						font-size: 18px;
						font-weight: 700;
					}
					.label-view {
						margin-right: 30rpx;
					}
				}
			}
		}
		
	}
</style>